﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<!--作为公共模版分离出去-->
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="admin/images/rookieCs.ico" />
	<link rel="Shortcut Icon" href="admin/images/rookieCs.ico" />
	<link rel="stylesheet" type="text/css" href="admin/static/h-ui/css/H-ui.my.css" />
	<link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/css/h-ui.admin.pro.iframe.min.css" />
	<link rel="stylesheet" type="text/css" href="admin/lib/Hui-iconfont/1.0.9/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="admin/lib/lc_switch/20160127/css/lc_switch.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/layui/2.5.6/css/layui.css" />
	<link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="admin/css/mywork.css" />
	<script type="text/javascript" src="admin/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="admin/lib/layer/3.1.1/layer.js"></script>
	<script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/plugins/datagrid-detailview.js"></script>
	<script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="admin/lib/lc_switch/20160127/js/lc_switch.min.js"></script>
    <script type="text/javascript" src="admin/lib/layui/2.5.6/layui.js"></script>
	<script>document.write('<script type="text/javascript" src="admin/js/common.js?v='+ Date.now() +'"><\/script>');</script>
	<script>document.write('<script type="text/javascript" src="admin/js/formatter.js?v='+ Date.now() +'"><\/script>');</script>
	<!--作为公共模版分离出去-->
	<title>审核回款申请</title>
    <link rel="stylesheet" type="text/css" href="admin/lib/zyUpload/control/css/zyUpload.css" />
	<script>document.write('<script type="text/javascript" src="admin/lib/zyUpload/core/zyFile.js?v='+ Date.now() +'"><\/script>');</script>
	<script>document.write('<script type="text/javascript" src="admin/lib/zyUpload/control/js/zyUpload.js?v='+ Date.now() +'"><\/script>');</script>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif" memuId="receipt-audit">
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en" style="float: none">&gt;</span> 回款管理
	<span class="c-gray en" style="float: none">&gt;</span> 审核回款申请
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div data-options="region:'center', border:false">
	<!--按钮元素-->
	<div id="buttonInfo" style="padding: 2px 0px 2px 5px; background-color: #F5FAFE;">
		<button class="easyui-linkbutton" onclick="query(pageParam, true)"><i class="Hui-iconfont">&#xe665;</i>查询</button>
		<button class="easyui-linkbutton" onclick="auditPass()"><i class="Hui-iconfont">&#xe615;</i>审核通过</button>
		<button class="easyui-linkbutton" onclick="auditNoPass()"><i class="Hui-iconfont">&#xe6dd;</i>审核不通过</button>
	</div>
	<!--表格元素-->
	<div id="tableInfo"></div>
</div>
<div data-options="region:'east', title:'查询条件', hideCollapsedContent:false, collapsible:true, collapsed:true" style="width:250px">
	<!--查询条件元素-->
	<form id="searchFormInfo" style="display: none">
		<div class="searchLabel">客户品牌：<input id="s_customerBrand" name="customerBrand"/></div>
		<div class="searchLabel">媒体名称：<input id="s_mediumName" name="mediumName"/></div>
		<div class="searchLabel"><input id="s_numberType" name="numberType" /><input id="s_numberStart" name="numberStart" />-<input id="s_numberEnd" name="numberEnd" /></div>
		<div class="searchLabel"><input id="s_dateType" name="dateType" /><input id="s_dateStart" name="dateStart" />-<input id="s_dateEnd" name="dateEnd" /></div>
		<div class="searchLabel">投放位置：<input id="s_putAddress" name="putAddress"/></div>
		<div class="searchLabel">状态：<input id="s_status" name="status"/></div>
	</form>
</div>
<script type="text/javascript">
    //准备函数
    $(function () {
        initSearchForm();
        initGrid();
        getGridHidden("tableInfo");
        query(pageParam);
    });

    //查询条件初始化
    function initSearchForm() {
		$("#s_customerBrand").textbox({
			width: 160
		});
		$("#s_mediumName").textbox({
			width: 160
		});
		$("#s_numberType").combobox({
			width: 220,
			panelHeight: "auto",
			valueField: "value",
			textField: "text",
			data: [{value:1, text:"回款金额", selected:true}, {value:2, text:"执行价"}, {value:3, text:"成本价"}]
		});
		$("#s_numberStart").numberbox({
			width: 108
		});
		$("#s_numberEnd").numberbox({
			width: 108
		});
		$("#s_dateType").combobox({
			width: 220,
			panelHeight: "auto",
			valueField: "value",
			textField: "text",
			data: [{value:1, text:"申请日期", selected:true}, {value:2, text:"审核日期"}, {value:3, text:"回款日期"}, {value:4, text:"投放日期"}]
		});
		$("#s_dateStart").datebox({
			width: 108,
			editable: false
		});
		$("#s_dateEnd").datebox({
			width: 108,
			editable: false
		});
		$("#s_putAddress").combobox({
			width: 160,
			panelHeight: "auto",
			valueField: "text",
			data: orderPutAddressDataAll
		});
		$("#s_status").combobox({
			width: 185,
			panelHeight: "auto",
			editable: false,
			data: receiptStatusDataAll
		});
		$("#s_status").combobox("setValue", 1);
		$("#searchFormInfo").show();
    }

    //表格元素初始化
    function initGrid() {
        $("#tableInfo").datagrid({
			pagination: true,
			singleSelect: false,
			fitColumns: false,
			striped: true,
			fit: true,
			frozenColumns: [[
				{field: "ck", checkbox: "true"},
				{field: "id", title: "回款编号", width: 70, align: "center", sortable: true, formatter: receiptIdFormatter},
				{field: "orderId", title: "排期编号", width: 70, align: "center", sortable: true},
				{field: "customerBrand", title: "客户品牌", width: 100, align: "center", sortable: true},
				{field: "mediumName", title: "媒体名称", width: 120, align: "center", sortable: true},
				{field: "mediumType", title: "媒体类型", width: 70, align: "center", sortable: true, formatter: mediumTypeFormatter},
				{field: "putDate", title: "投放日期", width: 90, align: "center", sortable: true, formatter: dateFormatter},
				{field: "putAddress", title: "投放位置", width: 80, align: "center", sortable: true}
			]],
			columns: [[
				{field: "quotedPrice", title: "执行价", width: 80, align: "center", sortable: true, formatter: orderQuotedPriceFormatter},
				{field: "costPrice", title: "成本价", width: 80, align: "center", sortable: true, formatter: orderCostPriceFormatter},
				{field: "profit", title: "利润", width: 100, align: "center", sortable: true},
				{field: "profitRate", title: "利润率", width: 70, align: "center", sortable: true, formatter: orderProfitRateFormatter},
				{field: "recMoney", title: "回款金额", width: 100, align: "center", sortable: true, formatter: receiptRecMoneyFormatter},
				{field: "recDate", title: "回款日期", width: 100, align: "center", sortable: true, formatter: dateFormatter},
				{field: "createUserId", title: "申请人", width: 80, align: "center", sortable: true, formatter: createUserIdFormatter},
				{field: "createDate", title: "申请时间", width: 140, align: "center", sortable: true, formatter: dateTimeFormatter},
				{field: "createDesc", title: "申请事由", width: 150, align: "left", sortable: false, formatter: remarkFormatter},
				{field: "auditUserId", title: "审核人", width: 80, align: "center", sortable: true, formatter: auditUserIdFormatter},
				{field: "auditDate", title: "审核时间", width: 140, align: "center", sortable: true, formatter: dateTimeFormatter},
				{field: "mediumUserName", title: "对接媒介", width: 80, align: "center", sortable: true},
				{field: "orderUserName", title: "对接销售", width: 80, align: "center", sortable: true},
				{field: "status", title: "状态", width: 80, align: "center", sortable: true, formatter: receiptStatusFormatter}
			]],
			toolbar: ".breadcrumb, #buttonInfo, #searchInfo",
			pageNumber: pageParam.pageNo,
			pageSize: pageParam.pageSize,
			pageList: Page.getPageList(),
			onSortColumn: function (orderBy, sortBy) {
				pageParam.pageNo = 1;
				pageParam.orderBy = orderBy;
				pageParam.sortBy = sortBy;
				query(pageParam);
			},
			onSelect: function() {
				selectedTableRow();
			},
			onUnselect: function() {
				selectedTableRow();
			},
			onSelectAll: function() {
				selectedTableRow();
			},
			onUnselectAll: function() {
				selectedTableRow();
			},
			onLoadSuccess: function() {
				toolBarBtnDisabledById([false, true, true], "buttonInfo");
			}
		}).datagrid("getPager").pagination({
			buttons: [
				{text: "个性化设置", iconCls: "icon-tip", handler: function() {selectColumnMenu("tableInfo");}},
				{text: "&emsp;<span id='sumQuotedPrice'></span>&emsp;<span id='sumCostPrice'></span>&emsp;<span id='sumRecMoney'></span>"}
			],
			onSelectPage: function(pageNumber, pageSize) {
				pageParam.pageNo = pageNumber;
				pageParam.pageSize = pageSize;
				query(pageParam);
			},
			onChangePageSize: function(pageSize) {
				pageParam.pageSize = pageSize;
			}
		});
        //表格事件
        var selectedTableRow = function() {
            var selectRow = $("#tableInfo").datagrid("getSelections");
            if (selectRow.length === 0) {
                toolBarBtnDisabledById([false, true, true], "buttonInfo");
            } else if (selectRow.length === 1) {
                toolBarBtnDisabledById([false, false, false], "buttonInfo");
            } else {
                toolBarBtnDisabledById([false, false, false], "buttonInfo");
            }
        };
    }

    //分页查询
    function query(pageParam, goHead) {
		pageParam.condition = getFormJson($("#searchFormInfo"));
		if (goHead && goHead)
			pageParam.pageNo = 1;
		ajaxGetFun("receipt/queryAuditReceiptPage", pageParam, function(bizData) {
			$("#tableInfo").datagrid("loadData", bizData.rowList);
			$("#tableInfo").datagrid("getPager").pagination({pageNumber: bizData.pageNo, total: bizData.total});
			//展示统计栏
			$("#sumQuotedPrice").html("总执行价："+ Number(bizData.statData.sumQuotedPrice).toFixed(2) +"元");
			$("#sumCostPrice").html("总成本价："+ Number(bizData.statData.sumCostPrice).toFixed(2) +"元");
			$("#sumRecMoney").html("总回款金额："+ Number(bizData.statData.sumRecMoney).toFixed(2) +"元");
		}, null, "获取待审核回款申请列表");
    }

    //审核通过
    function auditPass() {
        var selectRow = $("#tableInfo").datagrid("getSelections");
        if (selectRow.length === 0) {
            return showWarnMsg("请选择条目进行操作");
        }
        var html = '<div id="uploadDiv" style="margin: auto"></div>';
        openHtml(false, 700, 400, html, function() {
			$("#uploadDiv").zyUpload({
				width: "500px",
				height: "300px",
				itemWidth: "120px",
				itemHeight: "100px",
				multiple: true,
				dragDrop: false,
				preview: true,
				del: true,
				finishDel: false
			});
		}, function(index) {
			var files = ZYFILE.uploadFile;
			var formData = new FormData();
			var fileSize = 0;
			for (var i = 0; i < files.length; i++) {
				fileSize += files[i].size;
				formData.append("fileList", files[i]);
			}
			if (fileSize >= 10500000) {
				return showWarnMsg("文件总大小不能超过10M");
			}
			formData.append("ids", mergedRowCell(selectRow, "id"));
			ajaxUploadFun("receipt/setReceiptAuditPass", formData, function(bizData) {
				showSuccessMsg("已审核通过"+ bizData +"条数据");
				query(pageParam);
				layer.close(index);
			}, null, "审核通过回款申请");
		});
    }

    //审核不通过
    function auditNoPass() {
        var selectRow = $("#tableInfo").datagrid("getSelections");
		if (selectRow.length === 0) {
			return showWarnMsg("请选择条目进行操作");
		}
        layer.prompt("确认要审核不通过选中的回款申请吗？", function(value, index) {
            ajaxPostFun("receipt/setReceiptAuditNoPass", {ids: mergedRowCell(selectRow, "id"), auditDesc: value}, function(bizData) {
				showSuccessMsg("已审核不通过"+ bizData +"条数据");
				query(pageParam);
				layer.close(index);
			}, null, "审核不通过回款申请");
        });
    }
</script>
</body>
</html>